package com.briup.cms;


import net.sf.jsqlparser.statement.select.Wait;

class Num{
private static int count = 0 ;
    public static int getCount() {
        return count;
    }
    public static void setCount(int count) {
        Num.count = count;
    }
}
class testThread extends Thread{
    public testThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (true) {
            synchronized (Thread.class) {
                if (Num.getCount() > 200) {
                    break;
                }
                System.out.println(getName() +":" +Num.getCount());
                Num.setCount(Num.getCount() + 1);
                try {
                    Thread.class.notifyAll();
                    Thread.class.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}


public class test1 {
    public static void main(String[] args) {
        Thread t1 = new testThread("线程1");
        Thread t2 = new testThread("线程2");
        t1.start();
        t2.start();
    }
}
